﻿using System.Collections;
using System.Collections.Generic;
using M_CharactorSystem;
using UnityEngine;

public abstract class ICharactorAttr
{
    protected int MaxHp; //最大生命值
    protected int NowHp; //当前生命值
    protected float JumpHeight = 3; //跳跃高度
    protected float RollForwardSpeed = 0.0f; //前滚速度
    protected Vector3 RollbackSpeed; //后滚速度

    protected IAttrStrategy AttrStrategy = null; //属性的计算策略

    //设置计算策略
    public void SetAttrStrategy(IAttrStrategy theAttrStrategy)
    {
        AttrStrategy = theAttrStrategy;
    }

    public void Init(int maxHp)
    {
        MaxHp = maxHp;
        NowHp = MaxHp;
    }

    //获取当前生命值
    public int GetNowHp()
    {
        return NowHp;
    }

    //获取当前生命最大值
    public virtual int GetMaxHp()
    {
        return MaxHp;
    }

    //属性初始化
    public void InitAttr()
    {
        AttrStrategy.InitAttr(this);
    }

    //设置武器伤害附加值
    public int GetAtkplusValue()
    {
        return AttrStrategy.GetAtkplusValue(this);
    }

    //计算被攻击后的生命值
    public void GetDmgDesValue(ICharactor theAttacker)
    {
        //获取攻击者的攻击力
        int atkValue = theAttacker.GetAtkValue();
        //减少伤害值
        atkValue -= AttrStrategy.GetDmgDesValue(this);
        //计算生命值
        NowHp -= atkValue;
    }
    
}
